package Theard;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class Oval_Thread extends Thread{
	JPanel ve = new JPanel();
	public Oval_Thread(JPanel c){
		ve = c;
	}
	public void run(){
		int gh;
		if(ve.getWidth() < ve.getHeight()) gh = ve.getWidth();
		else gh = ve.getHeight();
		
		while(true){
			Graphics g = ve.getGraphics();
			g.setColor(new Color((int)(255.0*Math.random()),(int)(255.0*Math.random()),(int)(255.0*Math.random())));
			for(int i = gh/2; i >= 0; i--){
				g.fillOval(i, i, gh - 2*i, gh - 2*i);
				try{
					Thread.sleep(10);
				}catch (Exception e) {
					// TODO: handle exception
				}
			}
			
			g.setColor(new Color((int)(255.0*Math.random()),(int)(255.0*Math.random()),(int)(255.0*Math.random())));
			for(int i = 0; i <= gh/2; i++){
				g.drawOval(i, i, gh - 2*i, gh - 2*i);
				try{
					Thread.sleep(10);
				}catch (Exception e) {
					// TODO: handle exception
				}
			}
		}
	}
}
